package org.vic.mediator;

/**
 * 门派抽象类
 * Created by VIC.Huang on 2016/9/8.
 */
public abstract class School {
    public abstract String getName();

    // 加入中介者——模式联盟之前
    public School() {
    }

    public void defense() {
        System.out.println(getName() + "防御");
    }

    public void attack(School school) {
        System.out.println(getName() + "攻击" + school.getName());
    }

    // 加入中介者——模式联盟之后
    protected IPatternAlliance patternAlliance;

    public School(IPatternAlliance patternAlliance) {
        this.patternAlliance = patternAlliance;
    }

    public void attackByPatternAlliance(School passiveSide) {
        patternAlliance.resolveAttack(this, passiveSide);
    }

    public void defenseByPatternAlliance() {
        patternAlliance.resolveDefense(this);
    }
}
